package com.clss.commandhelper;

import android.content.Context;
import android.support.multidex.MultiDexApplication;

import com.amap.api.location.AMapLocation;
import com.clss.commandhelper.net.ApiClient;
import com.clss.commandhelper.net.ApiConfiguration;
import com.clss.commandhelper.net.ApiConstants;
import com.clss.commandhelper.tools.SdCard;

/**
 *
 * @author liuv
 * @date 2017/11/18
 */

public class CommandHelperApplication extends MultiDexApplication {
    private static final String TAG = "CommandHelperApplicatio";

    private static Context sAppContext;
    private static AMapLocation sMapLocation;

    @Override
    public void onCreate() {
        super.onCreate();
        SdCard.mkdirs();
        sAppContext = this.getApplicationContext();
        initApiClient(ApiConstants.DATA_SOURCE_TYPE_ONLINE);
//        initApiClient(ApiConstants.DATA_SOURCE_TYPE_TEST);
//        initApiClient(ApiConstants.DATA_SOURCE_TYPE_DEV);
    }

    public void initApiClient(int whichService){
        ApiConfiguration apiConfiguration = ApiConfiguration.builder()
                .dataSourceType(whichService)
                .build();
        ApiClient.init(apiConfiguration);
    }

    public static Context getAppContext(){
        return sAppContext;
    }

    public static AMapLocation getMapLocation() {
        return sMapLocation;
    }

    public static void setMapLocation(AMapLocation mapLocation) {
        sMapLocation = mapLocation;
    }
}
